﻿@model CuongHanh.Models.SubCategory
@(Html.X()
          .FormPanel()
          .Region(Region.Center)
          .Border(false)
          .StyleSpec("background-color:white;")
          .Padding(10)
          .Items(form =>
                     {
                         form.Add(Html.X().HiddenFor(m => m.Id));
                         form.Add(Html.X().HiddenFor(m => m.BranchId)
                                 );
                         form.Add(Html.X()
                                          .ComboBoxFor(m => m.CategoryId)
                                          .Width(500)
                                          .FieldLabel("Danh mục")
                                          .ForceSelection(true)
                                          .DisplayField("Name")
                                          .ValueField("Id")
                                          .EmptyText("Danh mục")
                                          .AllowBlank(false)
                                          .Store(Html.X().Store()
                                                         .AutoLoad(true)
                                                         .Model(Html.X().Model()
                                                                        .IDProperty("Id")
                                                                        .Fields(
                                                                                "Id",
                                                                                "Name"
                                                                        )
                                                         )
                                                         .Proxy(Html.X().AjaxProxy()
                                                                        .Json(true)
                                                                        .Url(Url.Action("GetCategoriesComboByBranch"))
                                                                        .ActionMethods(v => v.Read = HttpMethod.POST)
                                                                        .Reader(Html.X().JsonReader().Root("data").TotalProperty("total"))
                                                                        .ExtraParams(param => param.Add(new Parameter("branchId",
                                                                                                                      Model.BranchId + "",
                                                                                                                      ParameterMode.Value)))
                                                         )
                                                         .Listeners(ls =>
                                                                    ls.Load.Handler = "App.CategoryId.setValue(" + Model.CategoryId + ");"
                                                         )
                                          )
                                 );
                         form.Add(Html.X()
                                          .TextFieldFor(m => m.Code)
                                          .FieldLabel("Mã")
                                          .Width(500)
                                 );
                         form.Add(Html.X()
                                          .TextFieldFor(m => m.NameVi)
                                          .FieldLabel("Tên T.Việt")
                                          .Width(500)
                                 );
                         form.Add(Html.X()
                                          .TextFieldFor(m => m.NameEn)
                                          .FieldLabel("Tên T.Anh")
                                          .Width(500)
                                 );
                         form.Add(Html.X()
                                          .TextFieldFor(m => m.NameZh)
                                          .FieldLabel("Tên T.Hoa")
                                          .Width(500)
                                 );
                         form.Add(Html.X()
                                          .NumberFieldFor(m => m.No)
                                          .FieldLabel("Stt")
                                          .Width(500)
                                 );
                         form.Add(Html.X()
                                         .CheckboxFor(m => m.Invisible)
                                         .FieldLabel("Ẩn")
                                );
                         form.Add(Html.X()
                                          .Button()
                                          .ID("btUpdate")
                                          .Text("Lưu lại")
                                          .FormBind(true)
                                          .StyleSpec("margin-left:105px;")
                                          .DirectClickAction("Edit")
                                 );
                         form.Add(Html.X()
                                          .Button()
                                          .ID("btCancel")
                                          .Text("Hủy")
                                          .StyleSpec("margin-left:10px;")
                                          .OnClientClick("App.wdModify.hide();")
                                 );
                     }))